package com.woniuxy01;

import java.util.Arrays;

/**
 * @author 作者
 * @create 2025-11-05 10:42
 */
public class Test03 {
    public static void main(String[] args) {
//        System.out.println("aaa".concat("bbb"));
//        System.out.println("aaa".toUpperCase());
        String str = "aaa";
//        str=str.concat("bbb");
        str.concat("bbb");
        System.out.println(str);
        str = str.toUpperCase();
        System.out.println(str);

        StringBuilder sb=new StringBuilder("aaa");
        sb.append("bbb");
        sb.insert(1, "xxxx");
        System.out.println(sb);
    }

    private static void test06() {
        StringBuffer sb = new StringBuffer("aaa");
        System.out.println(sb);
        sb.append("bbb");
        System.out.println(sb);
    }

    private static void test05() {
        int[] a = {1, 2, 3};
        System.out.println(Arrays.toString(a));
        System.out.println(arrayToString(a));
    }

    public static String arrayToString(int[] a) {
        String str = "[";
        for (int i = 0; i < a.length; i++) {
            str = str.concat(a[i] + "");
            if (i != a.length - 1) {
                str = str.concat(", ");
            }
        }
        str = str.concat("]");
        return str;
    }

    static String stringReverse(String str) {
        return new StringBuilder(str).reverse().toString();
    }

    private static void test04() {
        StringBuilder sb = new StringBuilder("abcdefg");
        System.out.println(sb);
        sb.reverse();
        System.out.println(sb);
    }

    private static void test03() {
        StringBuilder sb = new StringBuilder("abcdefg");
//        sb.insert(1,"xyz");
        System.out.println(sb);
        sb.delete(2, 5);
        System.out.println(sb);
    }

    private static void test02() {
        StringBuilder sb = new StringBuilder("abc");
        sb.append("bbb");
        sb.append("ccc");
        sb.append("ddd");
        System.out.println(sb);
    }

    private static void test01() {
        StringBuilder sb = new StringBuilder("abc");
        System.out.println(sb);


        String str = new String("aaa");
        System.out.println(str);

        //StringBuilder和String不能直接转换
        String str1 = new String(sb);
        String str2 = sb.toString();

        StringBuilder sb1 = new StringBuilder(str);
    }
}
